/*
 * Filename:    AuditDispatchController.java
 * Copyright:   2014 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2014-11-10
 */
package com.paic.mhis.hcpms.workingArea.web.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.paic.mhis.core.auth.biz.service.Authority;
import com.paic.mhis.core.auth.biz.service.UserDetails;
import com.paic.mhis.hcpms.workingArea.biz.service.AuditWorkingAreaService;
import com.paic.mhis.hcpms.workingArea.web.vo.AuditWorkingAreaVO;
import com.paic.pafa.appclient.annotation.BizServicesProxy;

/**
 * 稽核 我的工作区
 * 
 * @author EX-XIEQI001
 * 
 */
@Controller
@RequestMapping("/auditWorkingArea/")
public class AuditWorkingAreaController {

	@BizServicesProxy(beanName = "auditWorkingAreaService")
	private AuditWorkingAreaService auditWorkingAreaService;

	/**
	 * 获取经办岗当前用户下待处理事件的数量
	 * 
	 * @param vo
	 * @param request
	 * @return
	 */
	@RequestMapping("getUnprocessedQuestion.do")
	@ResponseBody
	public Map<String, Object> getUnprocessedQuestion(HttpServletRequest request){
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
		map.put("assigner", user.getUsername().toUpperCase());
		List<Authority>  authorList=user.getAuthorities();
		List<String> roles = new  ArrayList<String>();
		for (Authority authority : authorList) {
			roles.add(authority.getAuthority());
		}
		map.put("roles", roles);
		result = auditWorkingAreaService.getUnprocessedQuestion(map);
		return result;
	}
	
	/**
	 * 获取经办岗当前用户下待处理事件列表以及总数
	 * 
	 * @param vo
	 * @param request
	 * @return
	 */
	@RequestMapping("queryProblemTaskList.do")
	@ResponseBody
	public Map<String, Object> queryProblemTaskList(@ModelAttribute AuditWorkingAreaVO vo , HttpServletRequest request){
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
		map.put("assigner", user.getUsername().toUpperCase());
		List<Authority>  authorList=user.getAuthorities();
		List<String> roles = new  ArrayList<String>();
		for (Authority authority : authorList) {
			roles.add(authority.getAuthority());
		}
		map.put("roles", roles);
		map.put("problemStatus", vo.getCode());
		result = auditWorkingAreaService.queryProblemTaskList(map);
		return result;
	}
	
	/**
	 * 获取经办岗当前用户下待处理事件列表以及总数
	 * 
	 * @param vo
	 * @param request
	 * @return
	 */
	@RequestMapping("queryCaseTaskList.do")
	@ResponseBody
	public Map<String, Object> queryCaseTaskList(@ModelAttribute AuditWorkingAreaVO vo , HttpServletRequest request){
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
		map.put("assigner", user.getUsername().toUpperCase());
		List<Authority>  authorList=user.getAuthorities();
		List<String> roles = new  ArrayList<String>();
		for (Authority authority : authorList) {
			roles.add(authority.getAuthority());
		}
		map.put("roles", roles);
		map.put("caseStatus", vo.getCode());
		result = auditWorkingAreaService.queryCaseTaskList(map);
		return result;
	}
	
	/**
	 * 获取审核岗当前用户下待处理事件的数量
	 * 
	 * @param vo
	 * @param request
	 * @return
	 */
	@RequestMapping("getAuditPost.do")
	@ResponseBody
	public Map<String, Object> getAuditPost(HttpServletRequest request){
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
		map.put("assigner", user.getUsername().toUpperCase());
		List<Authority>  authorList=user.getAuthorities();
		List<String> roles = new  ArrayList<String>();
		for (Authority authority : authorList) {
			roles.add(authority.getAuthority());
		}
		map.put("roles", roles);
		result = auditWorkingAreaService.getAuditPost(map);
		return result;
	}
	
	
	/**
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping("getQuestionCount.do")
	@ResponseBody
	public Map<String, Object> getQuestionCount(HttpServletRequest request){
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
		map.put("assigner", user.getUsername().toUpperCase());
		List<Authority>  authorList=user.getAuthorities();
		List<String> roles = new  ArrayList<String>();
		for (Authority authority : authorList) {
			roles.add(authority.getAuthority());
		}
		map.put("roles", roles);
		result = auditWorkingAreaService.getQuestionCount(map);
		return result;
	}
	
	/**
	 * 审核岗审批岗
	 * @param request
	 * @return
	 */
	@RequestMapping("getAllQuestionCount.do")
	@ResponseBody
	public Map<String, Object> getAllQuestionCount(HttpServletRequest request){
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
	//	map.put("assigner", user.getUsername().toUpperCase());
		List<Authority>  authorList=user.getAuthorities();
		List<String> roles = new  ArrayList<String>();
		for (Authority authority : authorList) {
			roles.add(authority.getAuthority());
		}
		map.put("roles", roles);
		result = auditWorkingAreaService.getQuestionCount(map);
		return result;
	}
	
	/**
	 * 审核岗审批岗
	 * @param request
	 * @return
	 */
	@RequestMapping("getQuestionProvider.do")
	@ResponseBody
	public Map<String, Object> getQuestionProvider(HttpServletRequest request){
		Map<String, Object> result = new HashMap<String, Object>();
		Map<String, Object> map = new HashMap<String, Object>();
		UserDetails user = (UserDetails) request.getSession().getAttribute("user");
	//	map.put("assigner", user.getUsername().toUpperCase());
		List<Authority>  authorList=user.getAuthorities();
		List<String> roles = new  ArrayList<String>();
		for (Authority authority : authorList) {
			roles.add(authority.getAuthority());
		}
		map.put("roles", roles);
		result = auditWorkingAreaService.getQuestionProvider(map);
		return result;
	}
	

}
